<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script>
        window.onload = function(){
          var demo = document.getElementById("demo");
            setInterval(fn,1000);  //  每隔1秒，就去 调用 一次 fn 这个函数
            var num = 1;
            function fn(){
                num++;
                demo.innerHTML = num ;
            }
        }
    </script>
</head>
<body>
 <div id="demo"></div>
</body>
</html>